﻿using Benefactor.Models.DbModels;
using Bigway.Common.Services.Repositories;
using SqlSugar;

namespace Benefactor.Services.Repositories;

public class VoucherRepository(IServiceProvider sp)
    : BaseSqliteEntityRepository<Voucher>(sp), IVoucherRepository
{
    public async Task<List<string>> GetDistinctIssuedBenefitsCardIdsAsync(
        Func<ISugarQueryable<Voucher>, ISugarQueryable<Voucher>> filter, 
        CancellationToken token = default)
    {
        var query = filter(Queryable);
        var issuedBenefitsCardIdQuery = query
            .Select(x => x.IssuedBenefitsCardId)
            .Distinct();
        return await issuedBenefitsCardIdQuery.ToListAsync(token);
    }
}